define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
	const ids = Fast.api.query('ids');

	const controller = {
    index() {
      // 设置添加窗口的大小
      // $(".btn-add").data('area', ['90%', '90%'])
      
			Table.api.init({
				extend: {
					index_url: 'business/source/index',
					add_url: 'business/source/add',
					edit_url: 'business/source/edit',
					del_url: 'business/source/del',
					table: 'business_source',
				},
			});

			const table = $('#table');

			table.bootstrapTable({
				// 请求地址
				url: $.fn.bootstrapTable.defaults.extend.index_url,
				// 设置工具栏元素
				toolbar: '.toolbar',
				// 设置主键
				pk: 'id',
				// 排序字段
				sortName: 'id',
				// 默认排序方式
				sortOrder: 'desc',
				showExport: false,
				// 渲染表格数据
				columns: [
					{ checkbox: true },
					{ field: 'id', title: 'ID', operate: false },
					{ field: 'name', title: __('SourceName') },
					{
						field: 'operate',
						title: __('Operate'),
						table: table,
						events: Table.api.events.operate,
						formatter: Table.api.formatter.operate,
					},
				],
			});

			Table.api.bindevent(table);
		},
		add() {
			controller.api.bindevent();
		},
		edit() {
			controller.api.bindevent();
		},
		del() {
			controller.api.bindevent();
		},
		api: {
			//JS模块化的全局方法
			bindevent: function () {
				Form.api.bindevent($('form[role=form]'));
			},
		},
	};

	return controller;
});
